<?php

namespace app\admin\model\steward;


use app\common\traits\ModelCurd;
use think\Model;

class AppsVersion extends Model
{
    use ModelCurd;
    protected $autoWriteTimestamp = true;
    protected $table = 'cp_apps_version';
    protected $json = ['support_category'];
    protected $jsonAssoc = true;

    public function getAppVersionCodeAttr($value,$data)
    {
        $info = [];
        switch ($value)
        {
            case 1:

                $info = [
                    "title"  => 'Alpha初步版',
                    "value"  => $value,
                    "v_code" => 'Alpha'
                ];
                break;
            case 2:

                $info = [
                    "title"  => 'Beta测试版',
                    "value"  => $value,
                    "v_code" => 'Beta'
                ];
                break;
            case 3:

                $info = [
                    "title"  => 'γ成熟版',
                    "value"  => $value,
                    "v_code" => 'γ'
                ];
                break;
            case 4:

                $info = [
                    "title"  => 'Trial试用版',
                    "value"  => $value,
                    "v_code" => 'Trial'
                ];
                break;
            case 5:

                $info = [
                    "title"  => 'Unregistered未注册版',
                    "value"  => $value,
                    "v_code" => 'Unregistered'
                ];
                break;
            case 6:

                $info = [
                    "title"  => 'Demo演示版',
                    "value"  => $value,
                    "v_code" => 'Demo'
                ];
                break;
            case 7:

                $info = [
                    "title"  => 'Release正式版',
                    "value"  => $value,
                    "v_code" => 'Release'
                ];
                break;
            case 8:

                $info = [
                    "title"  => 'Registered注册版',
                    "value"  => $value,
                    "v_code" => 'Registered'
                ];
                break;

        }
        return $info;
    }

    public function getSupportCategoryAttr($value,$data)
    {
        $info = [
            0 => [
                    "title"  => '其它',
                    "value"  => $value,
                ],
            1 => [
                "title"  => '安卓手机',
                "value"  => $value,
            ],
            2 =>  [
                "title"  => '苹果手机',
                "value"  => $value,
            ],
            3 => [
                "title"  => 'windows',
                "value"  => $value,
            ],
            4 => [
                "title"  => 'Mac',
                "value"  => $value,
            ],
            5 => [
                "title"  => '跨平台',
                "value"  => $value,
            ]
        ];
        $new_arr = [];
        if($value)
        {
            foreach ( $value as $v){
                if(isset($info[$v])) array_push($new_arr,$info[$v]);
            }
        }
        return $new_arr;
    }

}